package com.item.mofan.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.item.mofan.common.BaseContext;
import com.item.mofan.common.Result;
import com.item.mofan.dto.DishDto;
import com.item.mofan.dto.OrdersDto;
import com.item.mofan.entity.*;
import com.item.mofan.service.OrderDetailService;
import com.item.mofan.service.OrdersService;
import com.item.mofan.service.UserService;

import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.stream.Collectors;

@RestController
@Slf4j
@RequestMapping("/order")
public class OrderController {
    @Autowired
    private OrdersService ordersService;
    @Autowired
    private OrderDetailService orderDetailService;

    @PostMapping("/submit")
    public Result<String> submit(@RequestBody Orders orders) {
        ordersService.submit(orders);
        return Result.success("已提交订单");
    }

    @GetMapping("/userPage")
    public Result<Page> pageUser(int page, int pageSize) {
        Page<OrdersDto> pageInfo = ordersService.getUserPage(page, pageSize);
        return Result.success(pageInfo);
    }
    @GetMapping("/page")
    public Result<Page> page(int page, int pageSize, Orders orders,String endTime,String beginTime){
        Page<Orders> pageInfo = ordersService.getPage(page, pageSize,orders,endTime,beginTime);
        return Result.success(pageInfo);
    }
}


